package com.xxchat.controller;

import com.xxchat.annotation.GlobalInterceptor;
import com.xxchat.entity.constants.QueryConstants;
import com.xxchat.entity.po.UserInfoBeauty;
import com.xxchat.entity.query.UserInfoBeautyQuery;
import com.xxchat.entity.vo.PaginationResultVO;
import com.xxchat.entity.vo.ResponseVO;
import com.xxchat.service.UserInfoBeautyService;
import com.xxchat.service.UserInfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @author Waicc
 */
@RestController("adminUserInfoBeautyController")
@RequestMapping("/admin")
public class AdminUserInfoBeautyController extends ABaseController {
    @Resource
    private UserInfoService userInfoService;

    @Resource
    private UserInfoBeautyService userInfoBeautyService;

    @RequestMapping("/loadBeautyAccountList")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO loadBeautyAccountList() {
        UserInfoBeautyQuery query = new UserInfoBeautyQuery();
        query.setOrderBy(QueryConstants.ORDER_BY_ID_DESC);
        // TODO 传入 pageSize 和 pageNum 自己组装sql
        // TODO 搜索功能
        PaginationResultVO<UserInfoBeauty> resultVO = this.userInfoBeautyService.findListByPage(query);
        return getSuccessResponseVO(resultVO);
    }

    @RequestMapping("/saveBeautyAccount")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO saveBeautyAccount(@RequestBody UserInfoBeauty userInfoBeauty) {
        this.userInfoBeautyService.saveBeautyAccount(userInfoBeauty);
        return getSuccessResponseVO(null);
    }

    @RequestMapping("/delBeautyAccount")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO delBeautyAccount(@NotNull Integer id) {
        userInfoBeautyService.deleteUserInfoBeautyById(id);
        return getSuccessResponseVO(null);
    }
}
